package gold.digger;

import java.util.Arrays;

/**
 * Created by fanzhenyu02 on 2020/3/1.
 */
public class LC300 {
    public int lengthOfLIS(int[] arr) {
        if (null == arr || arr.length <= 0) {
            return 0;
        }

        int[] dp = new int[arr.length];
        Arrays.fill(dp, 1);

        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < i; j++) {
                if (arr[i] > arr[j]) {
                    dp[i] = Math.max(dp[i], dp[j] + 1);
                }
            }
        }

        int res = 0;
        for (int i = 0; i < dp.length; i++) {
            res = Math.max(res, dp[i]);
        }
        return res;
    }

    public static void main(String[] args) {
        LC300 an = new LC300();
        int[] arr = {10, 9, 2, 5, 3, 7, 101, 18};
        System.out.println(an.lengthOfLIS(arr));
    }
}
